package edu.qd.learn.newchapter.chapter04;

import java.util.Arrays;

/**
 * 可变字符序列
 *
 * @author 布衣
 */
public class LearnChangeString {

    public static void main(String[] args) {

        //可变字符序列
        String str0 = "abc";
//        private final char[] value;
        //不安全的
//        private char[] values;
        StringBuilder str = new StringBuilder();
        StringBuilder str11 = new StringBuilder("xyz");
        str11.insert(1,"ABC");

        str11.setCharAt(0,String.valueOf(str11.charAt(0)).toUpperCase().charAt(0));
        str11.delete(0,3);
        str11.setLength(0);


        str11.reverse();

        System.out.println(str11);

        //安全的 synchronized

        int[] as = {1,2,3,4,5,6,7,78,8,9,10};
        int[] as1 = new int[4];
        System.arraycopy(as,2,as1,0,4);

        System.out.println(Arrays.toString(as1));


        StringBuilder str12 = new StringBuilder("xyz");
        System.out.println(str12); //xyz
        System.out.println(str12);  // [x,y,z,,,,,,,,,,,,,,,]


//        public       任意位置
//        protected    本类  本包 子类
//        default      本类  本包
//        private      本类
        //synchronized 表示线程安全的方法 [同步锁]
        StringBuffer str1 = new StringBuffer();

    }

}
